#include "CTimer.h"

CTimer::CTimer( IrrlichtDevice *device ) : m_pDevice(device)
{
	if(device)
	{
		m_currentTime = 0;
		m_lastTime = 0;
		m_Error = false;
	}
	else 
	{
		cerr << "Error: device = NULL" << endl;
		m_Error = true;
	}
}

int CTimer::getCurrentTime()
{
	if(!m_Error)
	{
		m_currentTime = (m_pDevice->getTimer()->getTime() - m_lastTime);
		m_lastTime = m_currentTime;
		return m_currentTime;
	}
	else return -1;
}

void CTimer::resetTime()
{
	if(!m_Error)
	{
		m_currentTime = 0;
		m_lastTime = 0;
	}
}

